﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Text.Encodings.Web;
using System.Threading.Tasks;

namespace facebook.businuss.netcore.sdk.Utils
{
    public class RequestHelper
    {
        public static String constructUrlString(String apiUrl, Dictionary<String, Object> allParams)
        {
            StringBuilder urlString = new StringBuilder(apiUrl);
            bool firstEntry = true;
            foreach (var entry in allParams)
            {
                urlString.Append((firstEntry ? "?" : "&") + HttpUtility.UrlEncode(entry.Key,Encoding.UTF8) + "=" + HttpUtility.UrlEncode(Convert.ToString(entry.Value), Encoding.UTF8));
                firstEntry = false;
            }
            return urlString.ToString();
        }
    }
}
